//
//  ProtocolViewController.m
//  Sampux
//
//  Created by rzm on 16/7/4.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SampuxProtocolViewController.h"

@interface SampuxProtocolViewController ()<UIWebViewDelegate>

@property (nonatomic, strong) UIWebView *webView;
@end

@implementation SampuxProtocolViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setHidesBackButton:YES];

    SampuxCustomNavController *nav = (SampuxCustomNavController *)self.navigationController;
    nav.titleStr = @"桑普电器用户协议";

    UIImageView *backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    backImageView = backImageView;
    [self.view addSubview:backImageView];
    backImageView.userInteractionEnabled = YES;
    backImageView.image = imageNamed(@"backImg");
    
    UIButton *btn = [UIButton createButtonWithTitle:@"已阅" frame:CGRectMake(Sampux6WScale(90), self.view.height - 10 - Sampux6HScale(40), self.view.width - Sampux6WScale(90)*2, Sampux6HScale(40)) titleFont:THFont(16.) titleColor:THDeFaultBlueColor];
    [backImageView addSubview:btn];
    [btn setCorner:btn.height/2];
    btn.layer.borderWidth = 1;
    btn.layer.borderColor = THWhiteAlplaColor(0.6).CGColor;
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(10, 64 + 15, self.view.width - 20, btn.y - 25 - 64)];
    [backImageView addSubview:backView];
    [backView setCorner:5];
    backView.backgroundColor = [UIColor colorWithHex:0xffF6F6F6];
    
    NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
    NSString *filePath =[resourcePath stringByAppendingPathComponent:@"protocol.html"];
    NSString *htmlstring=[[NSString alloc] initWithContentsOfFile:filePath  encoding:NSUTF8StringEncoding error:nil];
    backView.backgroundColor = THSystemClearColor;
    
    self.webView = [[UIWebView alloc] initWithFrame:backView.bounds];
    [self.webView setScalesPageToFit:YES];
    self.webView.delegate = self;
//    self.webView.backgroundColor = [UIColor colorWithHex:0xffF6F6F6];
    self.webView.backgroundColor = THSystemClearColor;
    self.webView.opaque = NO;
    
    [self.webView loadHTMLString:htmlstring baseURL:[NSURL fileURLWithPath:[ [NSBundle mainBundle] bundlePath]]];
    [backView addSubview:self.webView];
    
}

- (void)btnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}





@end
